{include file="public/head"}

<body>
<div id="wrapper">
    {include file="public/menu"}

    <div id="page-wrapper" class="gray-bg dashbard-1">
        {include file="public/nav"}
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>系统维护</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="{:url('Index/index')}">主页</a>
                    </li>
                    <li>
                        <a>维护</a>
                    </li>
                    <li>
                        <strong>数据管理</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">

            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>数据列表</h5>
                        </div>

                        <div class="ibox-content">
                            <div class="row">
                                <div class="col-sm-1">
                                    <div class="input-group">
                                        <a href="javascript:;" onclick="data_add()" class="btn btn-sm btn-success"> 数据备份</a>
                                    </div>
                                </div>
                                <div class="col-sm-1">
                                    <div class="input-group">
                                        <a href="javascript:;" onclick="data_del()" class="btn btn-sm btn-danger"> 数据清空</a>
                                    </div>
                                </div>
                                <!--<div class="col-sm-1">-->
                                <!--    <div class="input-group">-->
                                <!--        <a href="javascript:;" onclick="settlement_day()" class="btn btn-sm btn-primary"> 模拟日结算</a>-->
                                <!--    </div>-->
                                <!--</div>-->
                                <div class="col-sm-1">
                                    <div class="input-group">
                                        <a href="javascript:;" onclick="settlement_month()" class="btn btn-sm btn-warning"> 模拟释放</a>
                                    </div>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>文件名称</th>
                                        <th>备份时间</th>
                                        <th>备份大小</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name="list" id="v"}
                                    <tr>
                                        <td>{$key+1}</td>
                                        <td>{$v.name}</td>
                                        <td>{$v.time}</td>
                                        <td>{$v.size}</td>
                                        <td>
                                            <a title="备份下载" href="{:url('dataOperation',['type'=>'dowonload','name'=>$v.name])}"><i class="fa fa-cloud-download text-success"></i></a>
                                            <!--<a title="备份还原" href="{:url('dataOperation',['type'=>'restore','name'=>$v.name])}" onclick="return confirm('备份还原后仅会显示当前备份的数据库的信息，您确定还原备份吗 ?')"><i class="fa fa-reply text-warning"></i></a>-->
                                            <a title="备份删除" href="{:url('dataOperation',['type'=>'del','name'=>$v.name])}" onclick="return confirm('数据库备份一旦删除不可找回，您确定操作吗?')"><i class="fa fa-trash text-danger"></i></a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        {include file="public/foot"}

    </div>
</div>
</div>
{include file="public/footer"}
<script>
    /*一键备份*/
    function data_add(){
        layer.confirm('备份数据的时间较长，确定要备份所有数据吗？',function(index){
            $.ajax({
                type:"POST",
                url:"{:url('Maintain/dataOperation')}",
                data:{
                    type:'backup',
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message, {icon: 6,time:1500},function () {
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

    /*一键清空*/
    function data_del(){
        layer.confirm('确认要清空吗？',function(index){
            $.ajax({
                type:"POST",
                url:"{:url('Maintain/DataDelete')}",
                data:{},
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message, {icon: 6,time:1500},function () {
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

    /*模拟日结算*/
    function settlement_day(){
        layer.confirm('确认要结算吗？',function(index){
            $.ajax({
                type:"POST",
                url:"{:url('Maintain/SettlementDay')}",
                data:{},
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message, {icon: 6,time:1500},function () {
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

    /*模拟释放*/
    function settlement_month(){
        layer.confirm('确认要释放吗？',function(index){
            $.ajax({
                type:"POST",
                url:"{:url('Maintain/shifang')}",
                data:{},
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message, {icon: 6,time:1500},function () {
                            window.top.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

</script>
</body>
</html>
